package com.mocha.bss.config;

import com.coffee.concurrent.CoffeeExecutorManager;
import com.coffee.middleware.dict.cache.EnumDictCacheManager;
import com.coffee.middleware.dict.service.CoffeeDictRedisServiceImpl;
import com.mocha.bss.domain.org.service.AdmdivService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * @author: songkui
 * @since: 2022/4/20 16:47
 */
@Component
@Order
@Slf4j
@AllArgsConstructor
public class StartInitialize implements ApplicationRunner {

    private final CoffeeDictRedisServiceImpl coffeeDictRedisService;
    private final AdmdivService admdivService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        CoffeeExecutorManager.getInstance().disruptor(8);
        coffeeDictRedisService.refreshAll(); //必须先刷新所有字典到redis
        admdivService.dataToRedis();
        EnumDictCacheManager.getInstance().initialize("com.coffee.basics.enumerate",
                "com.coffee.basics.enumerate.park",
                "com.coffee.basics.enumerate.enterprise");

    }

}
